<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="number" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目属性：</label>
                        <div class="layui-input-block">
                            <select id="business" name="business" lay-filter="business">
                                <option value="">请选择</option>
                                <option value="1">自营</option>
                                <option value="2">联营</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">项目状态：</label>
                        <div class="layui-input-block">
                            <select id="state" name="state" lay-filter="state">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">项目所属单位</label>
                        <div class="layui-input-block">
                            <div id="chanid" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">

</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>

    var param_enginid = getQueryVariable('enginid') || 0;
    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;

        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('进项票构成分析表');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_piao_fen_tai),where: {enginid:param_enginid}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {
                xmselect_dan('chanid', res.data.chanid, res.data.is_chanid, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                xiala_zhan_one_zuo('state', res.data.state, res.data.is_state);

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type:'numbers',title:'序号',totalRowText: '合计',fixed:'left'}
                ,{field:'name',title:'项目名称',templet: function(d){
                        return '<span class="colorlan" onclick="openPage(\'../engin/show.php?id='+d.id+'\')">'+d.name+'</span>';
                    }}
                ,{field: 'number', title: '项目编号'}
                ,{field: 'business_name', title: '项目属性'}
                ,{field: 'state_name', title: '项目状态'}
                ,{field:'shou_money',title:'进项票总额(元)',totalRow: true,align:'right',event: 'piao_shou',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.shou_money)+'</span>';
                    }}
                ,{field:'shou_money_cai',title:'进项票-材料费(元)',totalRow: true,align:'right',event: 'piao_shou_cai',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.shou_money_cai)+'</span>';
                    }}
                ,{field:'rate_cai',title:'占比(%)',totalRow: true,align:'right',templet: function(d){
                        return '<span class="">'+d.rate_cai+'</span>';
                    }}

                ,{field:'shou_money_ren',title:'进项票-人工费(元)',totalRow: true,align:'right',event: 'piao_shou_ren',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.shou_money_ren)+'</span>';
                    }}
                ,{field:'rate_ren',title:'占比(%)',totalRow: true,align:'right',templet: function(d){
                        return '<span class="">'+d.rate_ren+'</span>';
                    }}

                ,{field:'shou_money_ji',title:'进项票-机械设备费(元)',totalRow: true,align:'right',event: 'piao_shou_ji',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.shou_money_ji)+'</span>';
                    }}
                ,{field:'rate_ji',title:'占比(%)',totalRow: true,align:'right',templet: function(d){
                        return '<span class="">'+d.rate_ji+'</span>';
                    }}

                ,{field:'shou_money_fen',title:'进项票-专业分包费(元)',totalRow: true,align:'right',event: 'piao_shou_fen',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.shou_money_fen)+'</span>';
                    }}
                ,{field:'rate_fen',title:'占比(%)',totalRow: true,align:'right',templet: function(d){
                        return '<span class="">'+d.rate_fen+'</span>';
                    }}

                ,{field:'shou_money_qi',title:'进项票-其他费(元)',totalRow: true,align:'right',event: 'piao_shou_qi',templet: function(d){
                        return '<span class="colorlan">'+parseFormatNum(d.shou_money_qi)+'</span>';
                    }}
                ,{field:'rate_qi',title:'占比(%)',totalRow: true,align:'right',templet: function(d){
                        return '<span class="">'+d.rate_qi+'</span>';
                    }}
                ,{field: 'chanid_name', title: '项目所属单位'}
            ]]
            , done: function (res) {
                soulTable.render(this);
            }
        });

        table.on('tool(datalist)',function (obj) {
            var data = obj.data;
            if(obj.event === 'piao_shou'){
                openNavPage('查看项目收票信息','piao_shou/index.php?status=1&enginid='+data.id);
            }
            if(obj.event === 'piao_shou_cai'){
                openNavPage('查看项目收票明细信息','piao_shou/detail.php?status=1&yongtype=cai&enginid='+data.id);
            }
            if(obj.event === 'piao_shou_ren'){
                openNavPage('查看项目收票明细信息','piao_shou/detail.php?status=1&yongtype=ren&enginid='+data.id);
            }
            if(obj.event === 'piao_shou_ji'){
                openNavPage('查看项目收票明细信息','piao_shou/detail.php?status=1&yongtype=ji&enginid='+data.id);
            }
            if(obj.event === 'piao_shou_fen'){
                openNavPage('查看项目收票明细信息','piao_shou/detail.php?status=1&yongtype=fen&enginid='+data.id);
            }
            if(obj.event === 'piao_shou_qi'){
                openNavPage('查看项目收票明细信息','piao_shou/detail.php?status=1&yongtype=qi&enginid='+data.id);
            }
        });
        listTableSearch(form, table);
    });



</script>
</body>
</html>
